using System;
using System.Collections.Generic;
using System.Web;
using iPhOwa.Exchange.ContentClasses;
using iPhOwa.Exchange.Managers;

namespace iPhOwa.Web.Controls
{
	/// <summary>
	/// Lists the subfolders for a given path.
	/// </summary>
	public partial class FolderList : iPhOwaControl
	{
		/// <summary>
		/// Page_Load Event
		/// </summary>
		protected void Page_Load(object sender, EventArgs e)
		{
			ICollection<Folder> folders = FolderManager.GetList(Path, OwaSession);

			fl.DataSource = folders;
			fl.DataBind();
			fl.Visible = folders.Count > 0;
		}

		/// <summary>
		/// Get the proper page to link to based on the content class.
		/// </summary>
		protected static string GetPath(Uri href)
		{
			if(href == null)
			{
				throw new ArgumentNullException("href");
			}

			return string.Concat("ViewFolder.aspx?path=", HttpUtility.UrlEncode(href.ToString()));
		}
	}
}